package cate.common.table.item.yoke.row;

import cate.common.table.EExcelNoteField;
import cate.common.table.EExcelRowClass;
import cate.common.table.ERow;
import cp.solution.util.str.Str;

@EExcelRowClass
public class HeroLimitRow extends ERow {
    @EExcelNoteField(fieldName = "英雄原型ID")
    public int protoId;
    @EExcelNoteField(fieldName = "羁绊1")
    public String limit1;
    @EExcelNoteField(fieldName = "羁绊2")
    public String limit2;
    @EExcelNoteField(fieldName = "羁绊3")
    public String limit3;
    @EExcelNoteField(fieldName = "羁绊4")
    public String limit4;

    public Limit l1;
    public Limit l2;
    public Limit l3;
    public Limit l4;


    public static final class Limit {
        public int type;
        public int limit;

        public Limit(int type, int limit) {
            this.type = type;
            this.limit = limit;
        }
    }

    @Override
    public void decode() {
        super.decode();
        int[] l1s = Str.strArr2intArr(limit1.split(":"));
        if (l1s != null && l1s.length > 1) {
            l1 = new Limit(l1s[0], l1s[1]);
        }


        int[] l2s = Str.strArr2intArr(limit2.split(":"));
        if (l2s != null && l2s.length > 1) {
            l2 = new Limit(l2s[0], l2s[1]);
        }

        int[] l3s = Str.strArr2intArr(limit3.split(":"));
        if (l3s != null && l3s.length > 1) {
            l3 = new Limit(l3s[0], l3s[1]);
        }

        int[] l4s = Str.strArr2intArr(limit4.split(":"));
        if (l4s != null && l4s.length > 1) {
            l4 = new Limit(l4s[0], l4s[1]);
        }
    }

    public Limit getLimit(int pos) {
        switch (pos) {
            case 1:
                return l1;
            case 2:
                return l2;
            case 3:
                return l3;
            case 4:
                return l4;
            default:
                return null;
        }
    }
}
